package View;

import javax.swing.JOptionPane;

/**
 *
 * @author Tiago
 */
public class OperadorView extends javax.swing.JDialog {
    //variável para diferenciar alteração de inclusão. Inclusão = False, Alteração = True
    boolean alterar;
    int codigo;
    
    public OperadorView(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo( null );
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton2 = new javax.swing.JButton();
        pnOperadorCampo = new javax.swing.JPanel();
        cbOperadorFuncionario = new javax.swing.JComboBox();
        tfOperadorLogin = new javax.swing.JTextField();
        pfOperadorSenha = new javax.swing.JPasswordField();
        pfOperadorRepetirSenha = new javax.swing.JPasswordField();
        lbOperadorFuncionario = new javax.swing.JLabel();
        lbOperadorLogin = new javax.swing.JLabel();
        lbOperadorSenha = new javax.swing.JLabel();
        lbOperadorRepetirSenha = new javax.swing.JLabel();
        pnOperadorBotao = new javax.swing.JPanel();
        btOperadorSalvar = new javax.swing.JButton();
        btOperadorCancelar = new javax.swing.JButton();

        jButton2.setText("jButton2");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Operador do Sistema");

        pnOperadorCampo.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados de Operador do Sistema"));

        cbOperadorFuncionario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Preencher com os Funcionários do banco", "Item 2", "Item 3", "Item 4" }));

        tfOperadorLogin.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tfOperadorLoginKeyReleased(evt);
            }
        });

        lbOperadorFuncionario.setText("Funcionário:");

        lbOperadorLogin.setText("Login:");

        lbOperadorSenha.setText("Senha:");

        lbOperadorRepetirSenha.setText("Repetir Senha:");

        javax.swing.GroupLayout pnOperadorCampoLayout = new javax.swing.GroupLayout(pnOperadorCampo);
        pnOperadorCampo.setLayout(pnOperadorCampoLayout);
        pnOperadorCampoLayout.setHorizontalGroup(
            pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOperadorCampoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbOperadorFuncionario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbOperadorLogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbOperadorSenha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbOperadorRepetirSenha, javax.swing.GroupLayout.DEFAULT_SIZE, 94, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbOperadorFuncionario, 0, 250, Short.MAX_VALUE)
                    .addComponent(tfOperadorLogin)
                    .addComponent(pfOperadorSenha)
                    .addComponent(pfOperadorRepetirSenha))
                .addContainerGap())
        );
        pnOperadorCampoLayout.setVerticalGroup(
            pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnOperadorCampoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbOperadorFuncionario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbOperadorFuncionario))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfOperadorLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbOperadorLogin))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pfOperadorSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbOperadorSenha))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnOperadorCampoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pfOperadorRepetirSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbOperadorRepetirSenha))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnOperadorBotao.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btOperadorSalvar.setText("Salvar");
        btOperadorSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOperadorSalvarActionPerformed(evt);
            }
        });

        btOperadorCancelar.setText("Cancelar");
        btOperadorCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOperadorCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnOperadorBotaoLayout = new javax.swing.GroupLayout(pnOperadorBotao);
        pnOperadorBotao.setLayout(pnOperadorBotaoLayout);
        pnOperadorBotaoLayout.setHorizontalGroup(
            pnOperadorBotaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnOperadorBotaoLayout.createSequentialGroup()
                .addGap(89, 89, 89)
                .addComponent(btOperadorSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btOperadorCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnOperadorBotaoLayout.setVerticalGroup(
            pnOperadorBotaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnOperadorBotaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnOperadorBotaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btOperadorSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btOperadorCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnOperadorCampo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnOperadorBotao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnOperadorCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnOperadorBotao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btOperadorCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOperadorCancelarActionPerformed
        this.dispose();
    }//GEN-LAST:event_btOperadorCancelarActionPerformed

    private void btOperadorSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOperadorSalvarActionPerformed
        if((tfOperadorLogin.getText().equals("")) || (pfOperadorSenha.getPassword().length == 0) || (pfOperadorRepetirSenha.getPassword().length == 0)){
            JOptionPane.showMessageDialog(null, "Preencha os campos corretamente!");
        }
        else{
            if(alterar == false){
                //Inclui
            }
            else{
                //Altera
            }
        }
    }//GEN-LAST:event_btOperadorSalvarActionPerformed

    private void tfOperadorLoginKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfOperadorLoginKeyReleased
        tfOperadorLogin.setText(tfOperadorLogin.getText().toUpperCase());
    }//GEN-LAST:event_tfOperadorLoginKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(OperadorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(OperadorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(OperadorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OperadorView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                OperadorView dialog = new OperadorView(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btOperadorCancelar;
    private javax.swing.JButton btOperadorSalvar;
    private javax.swing.JComboBox cbOperadorFuncionario;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel lbOperadorFuncionario;
    private javax.swing.JLabel lbOperadorLogin;
    private javax.swing.JLabel lbOperadorRepetirSenha;
    private javax.swing.JLabel lbOperadorSenha;
    private javax.swing.JPasswordField pfOperadorRepetirSenha;
    private javax.swing.JPasswordField pfOperadorSenha;
    private javax.swing.JPanel pnOperadorBotao;
    private javax.swing.JPanel pnOperadorCampo;
    private javax.swing.JTextField tfOperadorLogin;
    // End of variables declaration//GEN-END:variables
}
